package designs.models.decorator.example.one;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ReadEnglishWord extends ReadWord {

	@Override
	public ArrayList<String> readWord(File file) {
		ArrayList<String> wordList = new ArrayList<String>();
		FileReader inOne = null;
		BufferedReader inTwo = null;
		try {
			inOne = new FileReader(file);
			inTwo = new BufferedReader(inOne);
			String str = null;
			while((str=inTwo.readLine()) != null) {
				wordList.add(str);
			};
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				if (inTwo != null) {
					inTwo.close();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally {
				try {
					if (inOne != null) {
						inOne.close();
					}
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		return wordList;
	}

}
